package com.headwind.mq.activemq.producer;

import com.headwind.entity.HwMood;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;

import javax.jms.Destination;

/**
 * @author : Headwind
 * @version : 1.0
 * @date : Created in 2020/8/10
 * @description : 消息生产者
 */
@Service
public class HwMoodProducer {
    private final JmsMessagingTemplate jmsMessagingTemplate;

    @Autowired
    public HwMoodProducer(JmsMessagingTemplate jmsMessagingTemplate) {
        this.jmsMessagingTemplate = jmsMessagingTemplate;
    }

    public void sendMessage(Destination destination, final String message) {
        jmsMessagingTemplate.convertAndSend(destination, message);
    }

    public void sendMessage(Destination destination, final HwMood hwMood) {
        jmsMessagingTemplate.convertAndSend(destination, hwMood);
    }
}
